﻿<UserControl x:Class="TeamProjectManager.Modules.SourceControl.SourceControlView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="clr-namespace:TeamProjectManager.Common.Infrastructure;assembly=TeamProjectManager.Common"
             xmlns:l="clr-namespace:TeamProjectManager.Modules.SourceControl"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <l:BranchInfoToolTipConverter x:Key="branchInfoToolTipConverter" />
    </UserControl.Resources>
    <Grid>

        <TabControl>

            <TabItem Header="View Settings" i:HelpProvider.HelpContent="Allows you to get an overview of the source control settings for each Team Project: whether or not &amp;multiple check-out&amp; and &amp;get latest on check-out&amp; are enabled, and which check-in notes are configured. Note that viewing the configured check-in policies is not supported at this time.">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>

                    <Button Grid.Row="0" Content="Get Source Control Settings" Command="{Binding Path=GetSourceControlSettingsCommand}" />

                    <DataGrid Grid.Row="1" Margin="0,5,0,0" ItemsSource="{Binding Path=SourceControlSettings}" IsReadOnly="True" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Team Project" Binding="{Binding Path=TeamProject}" />
                            <DataGridCheckBoxColumn Header="Multiple Check-out" Binding="{Binding Path=EnableMultipleCheckout}" />
                            <DataGridCheckBoxColumn Header="Get Latest On Check-out" Binding="{Binding Path=EnableGetLatestOnCheckout}" />
                            <DataGridTextColumn Header="Check-in Notes (* = Required)" Binding="{Binding Path=CheckinNoteFieldsList}" />
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>

            <TabItem Header="Update Settings" i:HelpProvider.HelpContent="Allows you to change the source control settings across multiple Team Projects. Note that configuring check-in policies is not supported at this time.">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Button Grid.Row="0" Content="Load From Team Project" Command="{Binding Path=LoadSourceControlSettingsCommand}" />

                    <Grid Grid.Row="1" Margin="0,5,0,0" DataContext="{Binding Path=SelectedSourceControlSettings}">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Content="Enable multiple check-out" IsChecked="{Binding Path=EnableMultipleCheckout}" />

                        <CheckBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,5,0,0" Content="Enable get latest on check-out" IsChecked="{Binding Path=EnableGetLatestOnCheckout}" />

                        <Label Grid.Row="2" Grid.Column="0" VerticalAlignment="Top" Content="Check-in Notes" />
                        <DataGrid Grid.Row="2" Grid.Column="1" Margin="5,5,0,0" ItemsSource="{Binding Path=CheckinNoteFields}" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" RowHeaderWidth="20">
                            <DataGrid.Columns>
                                <DataGridTextColumn Header="Display Order" Binding="{Binding Path=DisplayOrder}" />
                                <DataGridCheckBoxColumn Header="Required" Binding="{Binding Path=Required}" />
                                <DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" Width="*" />
                            </DataGrid.Columns>
                        </DataGrid>

                    </Grid>

                    <Button Grid.Row="2" Margin="0,5,0,0" Content="Update Source Control Settings" Command="{Binding Path=UpdateSourceControlSettingsCommand}" />
                </Grid>
            </TabItem>

            <TabItem Header="View Branch Hierarchies" i:HelpProvider.HelpContent="Allows you to get an overview of the branches across multiple Team Projects.">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Button Grid.Row="0" Content="Get Branch Hierarchies" Command="{Binding Path=ViewBranchHierarchiesCommand}" />
                    <TextBlock Grid.Row="1" Text="{Binding Path=BranchHierarchiesInfoMessage}" Margin="0,5,0,0" TextWrapping="Wrap">
                        <TextBlock.Style>
                            <Style TargetType="TextBlock">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=BranchHierarchiesInfoMessage}" Value="{x:Null}">
                                        <Setter Property="Visibility" Value="Collapsed" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                    <TreeView Grid.Row="2" Margin="0,5,0,0" ItemsSource="{Binding Path=BranchHierarchies}">
                        <TreeView.ItemContainerStyle>
                            <Style TargetType="{x:Type TreeViewItem}">
                                <Setter Property="IsExpanded" Value="True" />
                            </Style>
                        </TreeView.ItemContainerStyle>
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
                                <TextBlock Text="{Binding Path=Path}" ToolTip="{Binding Path=., Converter={StaticResource branchInfoToolTipConverter}}" />
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>
                    <WrapPanel Grid.Row="3" Margin="0,5,0,0">
                        <Button Content="Export" Command="{Binding Path=ExportBranchHierarchiesCommand}" />
                        <Label Content="As" Margin="5,0,0,0" VerticalAlignment="Center" />
                        <ComboBox Margin="5,0,0,0">
                            <ComboBoxItem Content="DGML" ToolTip="Directed Graph Markup Language (DGML) is a graph format that can be opened in Visual Studio 2010 or later" IsSelected="{Binding Path=ExportFormat, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Dgml}" />
                            <ComboBoxItem Content="XML" IsSelected="{Binding Path=ExportFormat, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Xml}" />
                        </ComboBox>
                        <CheckBox Margin="5,0,0,0" VerticalAlignment="Center" Content="Create one file per Team Project" ToolTip="Creates a file per Team Project instead of one file containing the full hierarchy" IsChecked="{Binding Path=ExportBranchHierarchiesPerTeamProject}" />
                    </WrapPanel>
                </Grid>
            </TabItem>

        </TabControl>

    </Grid>
</UserControl>